/**
 * 
 * Sun CMS
 * 
 * @author			Burning
 * @copyright		Copyright (c) 2009, SunWeber.Com.
 * @license			http://www.sunweber.com/license.htm
 * @link				http://www.sunweber.com/
 * @since				Version 1.1 Beta
 * 
 */

function sopen(str){$("#s_"+str).show();}
function sclose(str){$("#s_"+str).hide();}
function insert(str){$("#"+str[0]).attr("value",str[1]);$("#"+str[0]+'list').hide();sclose(str[0])}

/**editor-dialog宽高调节**/
function sceditor(w,h){$(".ke-dialog").css({"width":(w+20)+'px',"height":(h+63)+'px'});$(".sciframe").css({"width":w+'px',"height":h+'px'});}






function check_title()
{
	var title = $("#title").val();
	if(title=='')
	{
		$("#check_title").html('<img height="16" width="16" border="0" src="images/admin/publish_x.png"/>标题不能为空！');
		return false;
	}
	else
	{
		$("#check_title").html('');
		return true;
	}
}

function check_column(){
	var column_id=$("#column_id").val();
	if(column_id==0){
		$("#check_column").html('<img height="16" width="16" border="0" src="images/admin/publish_x.png"/>请选择栏目！');
		return false;
	}else{
		$("#check_column").html('');
		return true;
	}
}


function check_all_title(){
	var value = $("#title").val();
	if(value != ""){
		$.ajax({
			type: "POST",
			url: base_url+"?m=article&a=checktitle",
			data: {'title':value},
			dataType:'json',
			success: function(rs){
				if(rs.ok==1){
					$("#check_title").html('<img height="16" width="16" border="0" alt="否" src="images/admin/publish_x.png"/>已经有该标题文章！');
				}else{
					$("#check_title").html('<img height="16" width="16" border="0" alt="是" src="images/admin/tick.png"/>');
				}
			}
		});
	}
}

function select_af(str){
	if(str[1]==1){
		$("#"+str[0]+'list').show();
	}else if(str[1]==0){
		$("#"+str[0]+'list').hide();
	}
}



function select_co(){
	$("#color").show();
}

function color_select(str){
	$("#title_color").attr("value",str);
	$("#color").hide();
}

function showuploadfrom(str){
	if(str=='open'){
		$("#ajaxupload").show();
	}else if(str=='close'){
		$("#ajaxupload").hide();
	}
}

function ajaxFileUpload(str)
{
	$("#loading").ajaxStart(function(){$(this).show();}).ajaxComplete(function(){$(this).hide();});
	$.ajaxFileUpload
	({
		url:str,
		secureuri:false,
		fileElementId:'fileToUpload',
		dataType: 'json',
		success: function (data, status)
		{
			if(typeof(data.error) != 'undefined')
			{
				if(data.error != '')
				{
					alert(data.error);
				}else
				{
					$("#thumb_pic").attr("value",data.msg);
				}
			}
		},
		error: function (data, status, e)
		{
			alert(e);
		}
	});
	sclose('upload');
	return false;
}

//全选/反选
function checkall(str){
	if(str){
		$(".checkbox").each(function(){ 
			$(this).attr("checked", 'true'); 
		});
	}else{
		$(".checkbox").each(function(){ 
			$(this).removeAttr("checked");
		});
	}
}


function get_selected(){
	var selected = new Array();
	$(".checkbox").each(function(){
		if($(this).attr('checked')==true){
			selected.push($(this).val());
		}
	});
	return selected;
}


function mydata(){
	var GetTime = new Date();
    var Years = GetTime.getFullYear();
    var Months = GetTime.getMonth() + 1;
    var Days = GetTime.getDate();
    var Hours = GetTime.getHours();
    var Minutes = GetTime.getMinutes();
    var Seconds = GetTime.getSeconds();
    var Dn = 'AM';
	if (Months <= 9){ 
		Months ='0'+ Months;
	}
	if (Days <= 9){ 
		Days ='0'+ Days;
	}
	if (Hours<=9){ 
		Hours='0'+Hours;
	}
	if (Minutes<=9){
		Minutes='0'+Minutes;
	}  
	if (Seconds<=9){
		Seconds='0'+Seconds;
	}  
	now_time = Years + "-" + Months +"-"+ Days +" " + Hours +":"+ Minutes + ":"+Seconds; 
	return now_time;
}